package com.hugang.aboutcollection;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * 去除List中重复的数据
 *
 * @author hg
 * @date 2020/6/19 15:53
 */
public class ListToSetTest {

    public static void main(String[] args) {
        List list = new ArrayList();
        list.add(123);
        list.add(123);
        list.add(1234);
        list.add(1235);
        list.add(1236);
        list.add(123);

        System.out.println(list);

        Set set = new HashSet();
        set.addAll(list);
        System.out.println(set);
        list = new ArrayList(set);
        System.out.println(list);
    }
}
